package com.example.football.mapper;

import com.example.football.pojo.People;
import com.example.football.pojo.Peoplelikestar;
import com.example.football.pojo.Peopleliketeam;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PeopleMapper {
    /**
     *查看用户名是否已经存在
     * @param account
     * @return
     */
    @Select("select account,password from people  where account=#{account}")
    People findUserByAccount(@Param("account") String account);


    @Select("SELECT * FROM people WHERE id=#{id}")
    People findUserById(@Param("id") Integer id);


    /**
     * 注册
     * @param people
     */
    @Insert("insert into people values(#{id},#{account},#{password},#{name},#{byteam})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void register(People people);


    /**
     * 登录
     * @param people
     * @return
     */
    @Select("select id from people where account=#{account} and password=#{password}")
    Integer login(People people);

    @Select("select * from peopleliketeam where peopleid=#{id}")
    List<Peopleliketeam> findpeopleliketeam(People id);

    @Select("select * from peoplelikestar where peopleid=#{id}")
    List<Peoplelikestar> findpeoplelikestar(People id);

    @Delete("delete from peopleliketeam where peopleid=#{peopleid} and liketeam=#{liketeam}")
    void deletePeopleliketeam(Peopleliketeam peopleliketeam);

    @Insert("insert into peopleliketeam(peopleid,liketeam) values(#{peopleid},#{liketeam})")
    void insertPeopleliketeam(Peopleliketeam peopleliketeam);

    @Delete("delete from peoplelikestar where peopleid=#{peopleid} and likestar=#{likestar}")
    void deletePeoplelikestar(Peoplelikestar peoplelikestar);

    @Insert("insert into peoplelikestar(peopleid,likestar) values(#{peopleid},#{likestar})")
    void insertPeoplelikestar(Peoplelikestar peoplelikestar);

    @Update("update people set password=#{password} where id=#{id}")
    void updatePeople(People people);

}
